package br.com.swp.campestre.session;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Begin;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.framework.EntityQuery;
import org.jboss.seam.persistence.HibernateSessionProxy;

import br.com.swp.campestre.entity.Lote;

@Scope(ScopeType.CONVERSATION)
@Name("loteList")
public class LoteList extends EntityQuery<Lote> implements Serializable
{
	


	@In
	private HibernateSessionProxy hibernateSession;
	
	@Out
	private List<Lote> lotes;
	
	private String codigoLote;
//	private String cpfCandidato;
	


	

	@Begin(join=true)
	public void buscar(){
		
		Criteria crt =  hibernateSession.createCriteria(Lote.class);
		
		if( codigoLote != null && !codigoLote.equals("")){
			crt.add(Restrictions.eq("codigoLote", codigoLote));
		}
		
//		if( nomeCandidato != null && !nomeCandidato.equals("")){
//			crt.add(Restrictions.like("nome", "%"+nomeCandidato+"%"));
//		}
//		
//		if( cpfCandidato != null && !cpfCandidato.equals("")){
//			crt.add(Restrictions.eq("cpf", cpfCandidato));
//		}
		
//		if ( cargoList.getConcurso() != null) {
//			crt.createCriteria("cargo").add(Restrictions.eq("concurso", cargoList.getConcurso()));
//		}
		
//		if ( cargo != null) {
//			crt.add(Restrictions.eq("cargo", cargo));
//			
//		}
		
		
		lotes = crt.list();
		
    }





	public void setCodigoLote(String codigoLote) {
		this.codigoLote = codigoLote;
	}





	public String getCodigoLote() {
		return codigoLote;
	}





	public void setLotes(List<Lote> lotes) {
		this.lotes = lotes;
	}





	public List<Lote> getLotes() {
		return lotes;
	}






}
